package com.jt.assistant.ui

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.GridLayoutManager
import com.jt.assistant.R
import com.jt.assistant.adapter.HomeAdapter
import com.jt.assistant.bean.HomeBean
import com.jt.assistant.viewmodel.HomeViewModel
import com.yzp.mvvmlibrary.base.BaseActivity
import kotlinx.android.synthetic.main.activity_receipts_upload.*

/**
 * 单据上报
 */
class ReceiptsUploadActivity : BaseActivity<HomeViewModel>() {
    private var data = ArrayList<HomeBean>()
    private val mAdapter by lazy {
        HomeAdapter(
            ArrayList<HomeBean>()
        )
    }

    override fun layoutId(): Int = R.layout.activity_receipts_upload

    override fun initView(savedInstanceState: Bundle?) {
        with(rv_Receipts_upload) {
            layoutManager = GridLayoutManager(context, 2)
            adapter = mAdapter
        }
    }

    override fun initData() {
        getHomeData()
        mAdapter.data.addAll(data)
        mAdapter.notifyDataSetChanged()

    }

    override fun initListener() {
        mAdapter.setOnItemClickListener { adapter, view, position ->
            startActivity(Intent(this, mAdapter.data[position].aClass))
        }
    }

    private fun getHomeData() {
        data.add(
            HomeBean(
                "干线运单",
                R.mipmap.menu_item_icon_change_attribute_up,
                GxActivity::class.java
            )
        )
        data.add(
            HomeBean(
                "验收单",
                R.mipmap.menu_item_icon_accept_up,
                ReceiveActivity::class.java
            )
        )
//        data.add(
//            HomeBean(
//                "提货交接单",
//                R.mipmap.menu_item_icon_load_accept_up,
//                BillDeliveryActivity::class.java CarReceiveActivity
//            )
//        )
        data.add(
            HomeBean(
                "交接单",
                R.mipmap.menu_item_icon_collect_sort_up,
                BillDeliveryActivity::class.java
            )
        )
        data.add(
            HomeBean(
                "退供应商交接单",
                R.mipmap.menu_item_icon_collect_stock_up,
                ReturnReceiptsActivity::class.java
            )
        )
        data.add(
            HomeBean(
                "委托书查询",
                R.mipmap.menu_item_icon_move,
                EntrustBookActivity::class.java
            )
        )
        data.add(
            HomeBean(
                "装卸费上报",
                R.mipmap.menu_item_icon_loadbox_up,
                CarSearchActivity::class.java
            )
        )
        data.add(
            HomeBean(
                "自送装卸费上报",
                R.mipmap.menu_item_icon_move_location_up,
                CarSelfActivity::class.java
            )
        )
        data.add(
            HomeBean(
                "落地车辆查询",
                R.mipmap.menu_item_icon_move_by_goods_up,
                CarViewActivity::class.java
            )
        )

    }

}